import ShouldLogin from './ShouldLogin.vue'

export default {
  install (Vue) {
    let $vm
    Vue.$shouldLogin = {
      open (options) {
        console.log(options)
        if (!options) options = {}
        const Instance = Vue.extend(ShouldLogin)
        $vm = new Instance({
          el: document.createElement('div'),
          data: {
            path: typeof options.path != 'undefined' ? options.path : null,
            backClose: typeof options.backClose != 'undefined' ? options.backClose : true,
          },
        })
        // document.querySelector('#app').appendChild($vm.$el)
        console.log(options.path)
        console.log(options.backClose)
        document.body.appendChild($vm.$el)
      },
      close () {
        $vm && $vm.close(true)
      },
    }

    Vue.mixin({
      created () {
        this.$shouldLogin = Vue.$shouldLogin
      },
    })
  },
}
